Preserve errno, and always use g_strerror()
authorChristian Persch <chpe@gnome.org>
Thu, 20 Aug 2009 13:32:22 +0000 (15:32 +0200)
committerChristian Persch <chpe@gnome.org>
Mon, 24 Aug 2009 13:30:00 +0000 (15:30 +0200)
Bug #592461.

gdk-pixbuf/io-gif.c
gtk/gtkfilesel.c
gtk/gtkmountoperation-x11.c
gtk/updateiconcache.c

index 0a5803fb0cc1e5b4d6d7dff840f9aa1430a9c2f4..04fb1d11709417fd80db868728a230a145f47304 100644 (file)
@@ -220,7 +220,7 @@ gif_read (GifContext *context, guchar *buffer, size_t len)
                                      G_FILE_ERROR,
                                      g_file_error_from_errno (save_errno),
                                      _("Failure reading GIF: %s"), 
-                                     strerror (save_errno));
+                                     g_strerror (save_errno));
                 }
                 
 #ifdef IO_GIFDEBUG
index 0aa9f17d9178fca2b0b6598dfd09724c82731999..eca76ca910b57cb1270a00336150b7242f7aff7c 100644 (file)
@@ -1355,8 +1355,10 @@ gtk_file_selection_create_dir_confirmed (GtkWidget *widget,
 
   if (g_mkdir (sys_full_path, 0777) < 0)
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error creating folder '%s': %s"), 
-                            dirname, g_strerror (errno));
+                            dirname, g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
     }
 
@@ -1484,8 +1486,10 @@ gtk_file_selection_delete_file_response (GtkDialog *dialog,
 
   if (g_unlink (sys_full_path) < 0) 
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error deleting file '%s': %s"),
-                            fs->fileop_file, g_strerror (errno));
+                            fs->fileop_file, g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
     }
   
@@ -1602,9 +1606,11 @@ gtk_file_selection_rename_file_confirmed (GtkWidget *widget,
   
   if (g_rename (sys_old_filename, sys_new_filename) < 0) 
     {
+      int errsv = errno;
+
       buf = g_strdup_printf (_("Error renaming file \"%s\" to \"%s\": %s"),
                             sys_old_filename, sys_new_filename,
-                            g_strerror (errno));
+                            g_strerror (errsv));
       gtk_file_selection_fileop_error (fs, buf);
       goto out2;
     }
index 2a2c4a0046ff28658227bc166bef7c22d4bc39c0..1bfb50308b0d9a719227403c0eedab4700f25080 100644 (file)
@@ -952,6 +952,8 @@ _gtk_mount_operation_kill_process (GPid      pid,
 
   if (kill ((pid_t) pid, SIGTERM) != 0)
     {
+      int errsv = errno;
+
       /* TODO: On EPERM, we could use a setuid helper using polkit (very easy to implement
        *       via pkexec(1)) to allow the user to e.g. authenticate to gain the authorization
        *       to kill the process. But that's not how things currently work.
@@ -960,10 +962,10 @@ _gtk_mount_operation_kill_process (GPid      pid,
       ret = FALSE;
       g_set_error (error,
                    G_IO_ERROR,
-                   g_io_error_from_errno (errno),
+                   g_io_error_from_errno (errsv),
                    _("Cannot end process with pid %d: %s"),
                    pid,
-                   strerror (errno));
+                   g_strerror (errsv));
     }
 
   return ret;
index 627f49eb808a9e5d8ee0f25b37b2b4ea2434c7a7..02d004791165277d3eb23a78487788cafb9a5c79 100644 (file)
@@ -1516,9 +1516,11 @@ opentmp:
       g_unlink (bak_cache_path);
       if (g_rename (cache_path, bak_cache_path) == -1)
        {
+          int errsv = errno;
+
          g_printerr (_("Could not rename %s to %s: %s, removing %s then.\n"),
                      cache_path, bak_cache_path,
-                     g_strerror (errno),
+                     g_strerror (errsv),
                      cache_path);
          g_unlink (cache_path);
          bak_cache_path = NULL;
@@ -1528,16 +1530,22 @@ opentmp:
 
   if (g_rename (tmp_cache_path, cache_path) == -1)
     {
+      int errsv = errno;
+
       g_printerr (_("Could not rename %s to %s: %s\n"),
                  tmp_cache_path, cache_path,
-                 g_strerror (errno));
+                 g_strerror (errsv));
       g_unlink (tmp_cache_path);
 #ifdef G_OS_WIN32
       if (bak_cache_path != NULL)
        if (g_rename (bak_cache_path, cache_path) == -1)
-         g_printerr (_("Could not rename %s back to %s: %s.\n"),
-                     bak_cache_path, cache_path,
-                     g_strerror (errno));
+          {
+            errsv = errno;
+
+            g_printerr (_("Could not rename %s back to %s: %s.\n"),
+                        bak_cache_path, cache_path,
+                        g_strerror (errsv));
+          }
 #endif
       exit (1);
     }